﻿using System.ComponentModel.DataAnnotations;
using System.Reflection;

namespace Inovout
{
    public static class AliasHelper
    {
        public static string GetName(AliasAttribute aliasAttibute, DisplayAttribute displayAttribute, MemberInfo memberInfo)
        {
            return GetNameFromAliasAttribute(aliasAttibute) ??
                GetNameFromDisplayAttribute(displayAttribute) ??
                GetNameFromMemberInfo(memberInfo);
        }
        public static string GetNameFromAliasAttribute(AliasAttribute aliasAttibute)
        {
            return aliasAttibute == null ? null : aliasAttibute.Name;
        }
        public static string GetNameFromDisplayAttribute(DisplayAttribute displayAttribute)
        {
            return displayAttribute == null ? null : displayAttribute.Name;
        }
        public static string GetNameFromMemberInfo(MemberInfo memberInfo)
        {
            return memberInfo == null ? null : memberInfo.Name;
        }
    }
}
